import { createRouter, createWebHistory } from 'vue-router'

// 导入新增的注册页面组件
import Register from '../views/User/Register.vue'
import Profile from '../views/User/Profile.vue'

const routes = [
  // 首页改为登录页
  {
    path: '/',
    redirect: '/login' // 重定向到登录页
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/User/Login.vue'),
    meta: { hideNavbar: true } // 添加这行，隐藏导航栏
  },
  {
    path: '/find-password',
    name: 'FindPassword',
    component: () => import('../views/User/Find.vue'),
    meta: { hideNavbar: true } // 添加这行，隐藏导航栏
  },
  {
    path: '/register',
    name: 'Register',
    component: Register,
    meta: { hideNavbar: true } // 添加这行，隐藏导航栏
  },
  // 原有其他路由（保持不变，仅调整首页逻辑）
  {
    path: '/home', // 原首页改为'/home'路径，避免与登录页冲突
    name: 'Home',
    component: () => import('../views/Home.vue')
  },
  // 真题训练模块
  {
    path: '/training/record',
    name: 'TrainingRecord',
    component: () => import('../views/Training/TrainingRecord.vue')
  },
  {
    path: '/training/exam-detail/mock/:examId',
    name: 'MockExamDetail',
    component: () => import('../views/Training/MockExamDetail.vue'),
    meta: { title: '组卷考试详情' }
  },
  {
    path: '/training/exam-detail/past/:recordId',
    name: 'PastExamDetail',
    component: () => import('../views/Training/PastExamDetail.vue'),
    meta: { title: '真题考试详情' }
  },
  {
    path: '/training/mock-exam',
    name: 'MockExam',
    component: () => import('../views/Training/MockExam.vue')
  },
  {
    path: '/training/test',
    name: 'Test',
    component: () => import('../views/Training/Test.vue')
  },
  {
    path: '/training/exam',
    name: 'Exam',
    component: () => import('../views/Training/Exam.vue'),
    meta: { title: '套卷考试页面' }
  },
  {
    path: '/training/daily-practices',
    name: 'DailyPractices',
    component: () => import('../views/Training/DailyPractices.vue'),
    meta: { 
      title: '每日一练' // 中文标题
    }
  },
 {
  path: '/training/daily-practice-detail',
  name: 'DailyPracticeDetail',
  component: () => import('../views/Training/DailyPracticeDetail.vue'),
  meta: { requiresAuth: true },
  props: (route) => ({
    userId: route.query.userId,
    practiceId: route.query.practiceId
  })
},
  // 学习计划模块
  {
    path: '/study-plan/today',
    name: 'TodayPlan',
    component: () => import('../views/StudyPlan/TodayPlan.vue')
  },
  {
    path: '/study-plan/create',
    name: 'CreatePlan',
    component: () => import('../views/StudyPlan/CreatePlan.vue')
  },
  // 收藏夹模块
  {
    path: '/favorites/questions',
    name: 'MyQuestions',
    component: () => import('../views/Favorites/MyQuestions.vue')
  },
  {
    path: '/favorites/wrong-questions',
    name: 'WrongQuestions',
    component: () => import('../views/Favorites/WrongQuestions.vue')
  },
  // 发现模块
  {
    path: '/discover/ranking',
    name: 'Ranking',
    component: () => import('../views/Discover/Ranking.vue')
  },
  {
    path: '/discover/community',
    name: 'Community',
    component: () => import('../views/Discover/Community.vue')
  },
  // 数据统计
  {
    path: '/statistics',
    name: 'Statistics',
    component: () => import('../views/Statistics.vue')
  },
  // 用户模块 - 修改此处的name避免冲突
  {
    path: '/user/profile',
    name: 'UserProfile', // 修改为唯一名称
    component: () => import('../views/User/Profile.vue')
  },
  // 个人中心模块 - 保持原有配置
  {
    path: '/personal-center/info',
    name: 'PersonalInfo', // 修改为唯一名称
    component: () => import('../views/User/Profile.vue')
  },
  {
    path: '/personal-center/edit',
    name: 'EditProfile',
    component: () => import('../views/User/EditProfile.vue')
  },
  {
    path: '/personal-center/feedback',
    name: 'Feedback',
    component: () => import('../views/User/MessageFeedback.vue')
  },
  {
    path: '/personal-center/notifications',
    name: 'NotificationSettings',
    component: () => import('../views/User/NotificationSettings.vue')
  },
  {
    path: '/personal-center/cancel-account',
    name: 'CancelAccount',
    component: () => import('../views/User/AccountCancel.vue')
  },
  {
    path: '/community',
    name: 'CommunityA',
    component: () => import('../views/Discover/Community.vue')
  },
  {
    path: '/collect',
    name: 'Collections',
    component: () => import('@/views/User/Collect.vue')
  },
   // 添加收藏详情页路由 - 这是新增的路由
  {
    path: '/collect/detail/:id',
    name: 'CollectionDetail',
    component: () => import('@/views/User/Detail.vue'), // 确保这个路径正确
   
    },
    {
  path: '/post-detail/:postId',
  name: 'PostDetail',
  component: () => import('../views/Discover/viewDetail.vue'),
}
]

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
})

export default router